package com.ming.easyDevelop.controller;

import com.ming.easyDevelop.controller.base.BaseController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.ming.easyDevelop.service.OrderDetailsService;
import com.ming.easyDevelop.controller.base.ValidListBean;
import javax.validation.Valid;
import com.ming.easyDevelop.entity.po.OrderDetails;
import com.ming.easyDevelop.entity.vo.ResponseVo;
import com.ming.easyDevelop.entity.query.OrderDetailsQuery;
import java.util.List;
/**
 * @Description  Controller API
 * @Author ming
 * @Date 2024/07/10
 */
@RequestMapping("/api/orderDetails")
@RestController
public class OrderDetailsController extends BaseController {
	@Resource
	private OrderDetailsService orderDetailsService;

	@RequestMapping("/list")
	public ResponseVo getDataList(OrderDetailsQuery query){
		return getSuccessResponseVo(this.orderDetailsService.findListByParam(query));
	}
	@PostMapping("/add")
	public ResponseVo add(@Valid @RequestBody OrderDetails bean){
		this.orderDetailsService.add(bean);
		return getSuccessResponseVo(null);
	}

	@PostMapping("/addOrUpdate")
	public ResponseVo addOrUpdate(@Valid @RequestBody OrderDetails bean){
		this.orderDetailsService.addOrUpdate(bean);
		return getSuccessResponseVo(null);
	}

	@PostMapping("/addBatch")
	public ResponseVo addBatch(@RequestBody ValidListBean<OrderDetails> list){
		this.orderDetailsService.addBatch(list.getData());
		return getSuccessResponseVo(null);
	}

	@PostMapping("/addOrUpdateBatch")
	public ResponseVo addOrUpdateBatch(@RequestBody ValidListBean<OrderDetails> list){
		this.orderDetailsService.addOrUpdateBatch(list.getData());
		return getSuccessResponseVo(null);
	}

	/**
	 * 根据OrderDetailID查询
	 */
	@GetMapping("/orderDetailID")
	public ResponseVo getByOrderDetailID(Integer orderDetailID){
		return getSuccessResponseVo(this.orderDetailsService.getByOrderDetailID(orderDetailID));
	}

	/**
	 * 根据OrderDetailID更新
	 */
	@PutMapping("/orderDetailID")
	public ResponseVo updateByOrderDetailID(@Valid OrderDetails bean, Integer orderDetailID){
		this.orderDetailsService.updateByOrderDetailID(bean,orderDetailID);
		return getSuccessResponseVo(null);
	}

	/**
	 * 根据OrderDetailID删除
	 */
	@DeleteMapping("/orderDetailID")
	public ResponseVo deleteByOrderDetailID(Integer orderDetailID){
		this.orderDetailsService.deleteByOrderDetailID(orderDetailID);
		return getSuccessResponseVo(null);
	}

}